// message.js
import { Message } from 'element-ui'

export default class ShowMessage {
  success(options) {
    this.message('success', options)
  }

  warning(options) {
    this.message('warning', options)
  }

  info(options) {
    this.message('info', options)
  }

  error(options) {
    this.message('error', options)
  }

  message(type, options) {
    const messageDom = document.getElementsByClassName('el-message')[0]
    if (messageDom === undefined) {
      Message[type](options)
    } else {
      Message.closeAll()
      Message[type](options)
    }
  }
}
